import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { autoComplete, Plugin as importToCDN } from "vite-plugin-cdn-import";
const BASE_URL = process.env.NODE_ENV === 'production' ? '/app/pan': ''
// https://vitejs.dev/config/
export default defineConfig({
    base: BASE_URL,    
    plugins: [
        vue(),
        importToCDN({
            modules: [
                {
                    name: 'vue',
                    var: 'Vue',
                    path: `https://cdn.staticfile.net/vue/3.3.4/vue.global.min.js`,
                },
                {
                    name: 'vue-demi',
                    var: 'VueDemi',
                    path: `https://cdn.staticfile.net/vue-demi/0.14.6/index.iife.min.js`,
                },
                {
                    name: 'vue-router',
                    var: 'VueRouter',
                    path: `https://cdn.staticfile.net/vue-router/4.2.5/vue-router.global.min.js`,
                },
                {
                    name: 'pinia',
                    var: 'Pinia',
                    path: `https://cdn.staticfile.net/pinia/2.1.7/pinia.iife.min.js`,
                },
                {
                    name: 'element-plus',
                    var: 'ElementPlus',
                    path: `https://cdn.staticfile.net/element-plus/2.5.1/index.full.min.js`,
                    css: 'https://cdn.staticfile.net/element-plus/2.5.1/index.min.css'
                },
                {
                    name: '@element-plus/icons-vue',
                    var: 'ElementPlusIconsVue ',
                    path: `https://cdn.staticfile.net/element-plus-icons-vue/2.3.1/index.iife.min.js`
                }
            ]
        }),
    ],
    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src', import.meta.url))
        }
    }
})
